# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgname=monero-gui
pkgver=0.18.3.1
_commit=bea3032df9b1fc59a7aa0a3489d583b389481cfe
pkgrel=3
pkgdesc="Qt GUI wallet for Monero: the secure, private, untraceable peer-to-peer currency"
license=('BSD-3-Clause')
arch=('loong64' 'x86_64')
url="https://getmonero.org/"
depends=(
  'hicolor-icon-theme'
  'libunbound.so'
  'libboost_program_options.so'
  'libgcrypt'
  'libhidapi-libusb.so'
  'libsodium'
  'libssl.so'
  'libudev.so'
  'libunbound.so'
  'libunwind'
  'libusb'
  'monero'
  'pcsclite'
  'qt5-base'
  'qt5-declarative'
  'qt5-graphicaleffects'
  'qt5-quickcontrols'
  'qt5-quickcontrols2'
  'qt5-svg'
  'qt5-xmlpatterns'
)
makedepends=(
  'boost'
  'cmake'
  'git'
  'python'
  'qt5-tools'
)
source=(
  "git+https://github.com/monero-project/monero-gui?signed#commit=${_commit}"
  "git+https://github.com/monero-project/monero"
  "git+https://github.com/dlbeer/quirc.git"
  "git+https://github.com/miniupnp/miniupnp.git"
  "git+https://github.com/Tencent/rapidjson.git"
  "git+https://github.com/trezor/trezor-common.git"
  "git+https://github.com/tevador/RandomX.git"
  "git+https://github.com/monero-project/supercop.git"
  "monero-gui.desktop"
)
sha512sums=('SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            '98b67aec60e492f0a220a156a110baf96862343d3802ec34347c70c7af671a1ae49ccaec218f2e8f81e153c433e9145ad2f55b8613ce6999fc2c87fbd81fd8e1')
validpgpkeys=(
  '8777AB8F778EE89487A2F8E7F4ACA0183641E010' # luigi1111 <luigi1111w@gmail.com>
  '487277A8BD0A209C16B700F3C64552D877C32479' # Alexander Blair (Snipa / Snipa22) <snipa@jagtech.io>
)

prepare() {
  cd "${pkgname}"
  git submodule init
  git config submodule.monero.url "$srcdir/monero"
  git config submodule.external/quirc.url "$srcdir/quirc"
  git -c protocol.file.allow=always submodule update
  cd monero
  git config submodule.external/miniupnp.url "$srcdir/miniupnp"
  git config submodule.external/rapidjson.url "$srcdir/rapidjson"
  git config submodule.external/trezor-common.url "$srcdir/trezor-common"
  git config submodule.external/randomx.url "$srcdir/RandomX"
  git config submodule.external/supercop.url "$srcdir/supercop"
  git -c protocol.file.allow=always submodule update

# Fix build with GCC 13
  git cherry-pick -n c32befe4f8385f5f893c0db611060bc7c7b425f3
# Fix build with protobuf 23
  sed -e 's|CMAKE_CXX_STANDARD 14|CMAKE_CXX_STANDARD 17|' -i CMakeLists.txt
}

build() {
  cd "${pkgname}"
  mkdir -p build && cd build
  cmake -D CMAKE_BUILD_TYPE=Release -D ARCH=default -D WITH_DESKTOP_ENTRY=OFF -D WITH_UPDATER=OFF ../
  make
}

package() {
  cd "${pkgname}"
  install -Dm755 build/bin/monero-wallet-gui -t "${pkgdir}/usr/bin"
  install -Dm644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"

  install -Dm644 ../monero-gui.desktop -t "${pkgdir}/usr/share/applications"
  for x in 16 24 32 48 64 96 128 256; do
    install -Dm644 "images/appicons/${x}x${x}.png" "${pkgdir}/usr/share/icons/hicolor/${x}x${x}/apps/monero-gui.png"
  done
}

# vim: ts=2 sw=2 et:
